﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jian.Vubackup.MySql
{
    public class Group
    {
        public List<GroupItem> groupList { get; set; }
        public Group()
        {
            groupList = new List<GroupItem>();
        }

        public void AddFileItem(FileInfoItem item)
        {
            GroupItem groupItem = groupList.Where(t => t.GroupName == item.DbName).FirstOrDefault();
            if (groupItem == null)
            {
                groupItem = new GroupItem(item.DbName);
                groupItem.FileList.Add(item);
                groupList.Add(groupItem);
            }
            else
            {
                groupItem.FileList.Add(item);
            }
        }

        public void Clear()
        {
            if (groupList != null && groupList.Count > 0)
            {
                foreach (GroupItem item in groupList)
                {
                    item.Clear();
                }
            }
        }
    }
}
